package com.yhert.study.springcloud.study01.service.user;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.cloud.client.SpringCloudApplication;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.yhert.study.springcloud.study01.service.user.beans.User;

@EnableHystrix
@EnableEurekaClient
@EnableFeignClients
@SpringCloudApplication
@RestController
@RefreshScope
@EnableAspectJAutoProxy(proxyTargetClass = true)
@EnableHystrixDashboard
public class StartMain {
	private static final Logger log = LoggerFactory.getLogger(StartMain.class);

	@Value("${app.user.pre.name}")
	private String preName;

	@RequestMapping("user/{username}")
	public User getUser(@PathVariable("username") String username) {
		log.info("===============>>>user:" + username);
		return new User(username, this.preName + "passwd" + username);
	}

	public static void main(String[] args) {
		SpringApplication.run(StartMain.class, args);
	}

}
